<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/commons/jsp/taglibs.jsp"%>
<%@taglib uri="http://www.framework.com/taglib" prefix="frame"%>
  <head>
	<title>公共平台 </title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<!-- 样式文件的引入 -->
	<link href="${ctx}/commons/css/style.css" rel="stylesheet" type="text/css"/>
	<link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/icon.css">
	<!-- jqueryUI JS文件的引入 -->
	<script type="text/javascript" src="${ctx}/commons/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="${ctx}/commons/js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${ctx}/commons/js/easyui-extends-validate.js"></script>
	<!-- jqueryUI国际化 -->
	<script type="text/javascript" src="${ctx}/commons/js/easyui-lang-zh_CN.js"></script>
	<!-- 开发使用的公用js方法 -->
	<script type="text/javascript" src="${ctx}/commons/js/common.js"></script>
	<!-- 开发国际化的引用，主要完成后台信息在前台提示的国际化，一定要放在最后 -->
	<script type="text/javascript">var ctx = '${ctx}';var actionExt = "action";var i18n = new Object();</script>
	<script src="${ctx}/commons/js/i18n/message_zh_CN.js" type="text/javascript"></script>
  </head>
  
  <body>
    <div class="easyui-layout" data-options="fit:true,border:false" >
			<div data-options="region:'north',border:false" style="padding: 4px;height: 80px;overflow: hidden;">
			<div class="easyui-panel" data-options="fit:true,border:true" >
			<div  class="queryContent">
				<form name="searchProjectsForm" id="searchProjectsForm" method="post" action="" style="display: none; ">
				<table class="queryTable" >
					<tbody>
						<tr>
							<th >项目名称</th>
							<td width="10%">
								<input id="name" class="easyui-validatebox" type="text" name="name"  maxlength="50" style="width:120px;height: 15px;"/>
							</td>
							<th>项目编号</th>
							<td>
							 	<input id="code" class="easyui-validatebox" type="text" name="code"  maxlength="20" style="width:120px;height: 15px;"/>
							</td>
							<th >项目类型</th>
							<td width="10%">
								<select class="easyui-combobox" name="catagoryId" style="width:120px;height: 25px;" maxlength="20" data-options="">
									<option value="">--请选择--</option>
									<c:forEach items="${projectTypeList}" var="type">
										<option value="${type.id}">${type.name}</option>
									</c:forEach>
								</select>
							</td>
							<!-- 
								<th >资金来源</th>
							<td>
							 	<select id="moneySource" style="width:120px" class="easyui-combobox" name="moneySource">
							 		<option value="">--请选择--</option>
									<c:forEach items="${frame:dictChildren('moneySource')}" var="type">
										<option value="${type.value}">${type.name}</option>
									</c:forEach>
								</select>
							</td>
							 --> 
							<th  >状态</th>
							<td>
							 	<select id="status" style="width:120px;height: 25px;" class="easyui-combobox" name="status">
							 		<option value="">--请选择--</option>
									<c:forEach items="${frame:dictChildren('proj_status')}" var="type">
										<option value="${type.value}">${type.name}</option>
									</c:forEach>
								</select>
							</td>
						</tr>
						<tr>
							<th>创建时间</th>
							<td>
								<input id="startTime" class="easyui-datebox" type="text" name="startTime"  data-options="validType:['dateTimeLessCompare[\'stopTime\']']" maxlength="20" style="width:120px;height: 25px;"/>-<input id="stopTime" class="easyui-datebox" type="text"  data-options="validType:['dateTimeMoreCompare[\'startTime\']']" name="stopTime" maxlength="20" style="width:120px;height: 25px;"/>
							</td>
							<th>开标时间</th>
							<td>
							 	<input id="startTime" class="easyui-datebox" type="text" name="bidTime"  data-options="validType:['dateTimeLessCompare[\'stopTime\']']" maxlength="20" style="width:120px;height: 25px;"/>-<input id="stopTime" class="easyui-datebox" type="text"  data-options="validType:['dateTimeMoreCompare[\'startTime\']']" name="bidStopTime" maxlength="20" style="width:120px;height: 25px;"/>
							</td>
							<!-- 
							<th>预算金额(元)</th>
							<td>
							 	<input id="startMoney" class="easyui-validatebox" type="text" name="startMoney"  data-options="validType:['rangeLessCompare[\'endMoney\']']" maxlength="20" style="width:120px"/>-<input id="endMoney" class="easyui-validatebox" type="text"  data-options="validType:['rangeMoreCompare[\'startMoney\']']" name="endMoney" maxlength="20" style="width:120px"/>
							</td>
							-->
							<th></th>
							<td align="right" colspan="3">
								<a href="javascript:void(0);" class="easyui-linkbutton" id="searchProjects" iconcls="icon-search" plain="true">查询</a>
								<a href="javascript:void(0);" class="easyui-linkbutton" id="resetsearchProjects" iconcls="icon-reset" plain="true">清空</a>
							</td>
						</tr>
					</tbody>
				</table>
				</form>
			</div>
			</div>
			</div>
			<div data-options="region:'center',border:false" style="padding: 4px;">
		    <table id="listProjectsTable" class="easyui-datagrid" 
				data-options="singleSelect:false,toolbar:'#goodstb',method:'post',rownumbers:true,fit:true,fitColumns:true,border:true,
					pagination:true,multiSort:true,remoteSort:true,striped:true,onLoadSuccess:function(data){$('#'+projectsParamObj.searchID).attr('disabled',false);},
					url:'${ctx}/business/projectmanage/list?roleId=bizmanager'"}>
				<thead>
					<tr>
						<th data-options="field:'name',width:170,title:'项目名称',sortable:true" align="center"></th>
						<th data-options="field:'code',width:90,title:'项目编号',sortable:true" align="center"></th>
						<th data-options="field:'catagoryName',width:80,title:'项目类型',sortable:true" align="center"></th>
						<th data-options="field:'auditable',width:80,title:'竞价发起人',sortable:true,formatter: function(value,row,index){if(value==true){return '公共资源交易中心';}else{{return '采购人';}}}" align="center"></th>
						<th data-options="field:'buyName',width:120,title:'采购人',sortable:true" align="center"></th>
						<th data-options="field:'manageName',width:100,title:'项目负责人',sortable:true" align="center"></th>
						<th data-options="field:'createTime',width:100,title:'创建时间',sortable:true" align="center"></th>
						<th data-options="field:'bidStartTime',width:80,title:'开标时间 ',sortable:true" align="center"></th>
						<th data-options="field:'statusName',width:80,title:'状态',sortable:true" align="center"></th>
						<th data-options="field:'operation',width:160,title:'操作'" align="center"></th>
				</tr>
				</thead>
			</table>
			
			<!----------------------- wei start --------------------->
			<!--导出Excel -->
			<input type="hidden" id="excel_error" value="${requestScope.excel_error }"/>
			<script type="text/javascript">
		    	//导出
				function excelexport(){
					$("form").attr("action","${ctx}/business/projectmanage/export")
					$("form").submit();

					var val=$("#excel_error").val();
					if(val!=""){//不为空提示错误消息
						 top.$.messager.alert("操作提示", val,"error");  
					}
				}
				
		    </script>
			<!----------------------- wei end --------------------->		
		</div>
	</div>
	<div id="bindPicDialog"></div>
	<div id="selPicDialog"></div>
	<div id="noCompetReasonDialog"></div>
</body>
	<script type="text/javascript">
		//初始化表格对应的js对象
		var projectsParamObj;
		$(function() {
			//初始化表格对象数据
			projectsParamObj = new initParams(
					{
						paramObjName : 'projectsParamObj',//表格对应的实体对象名称，好区分多个表格情况下的对象
						tableId:'listProjectsTable',
						addDataFormId:'addProjectsDataForm',
						showDialogId:'firstLevelDialog',
						searchID:'searchProjects',
						resetSearchID:'resetsearchProjects',
						searchFormID:'searchProjectsForm',
						updateUrl:"${ctx}/business/projectmanage/input?projectId=",
						deleteUrl:'${ctx}/business/projectmanage/remove',
						addDialogWidth:700,
						addDialogHeight:520,
						ctx:'${ctx}',
						addDialogTitle:'采购项目信息'
					});
			//初始化查询
			init(projectsParamObj);
			//setTimeout(function(){
				//$.parser.parse(".optionsAreas");
			//},1000);
		});
		
		/**
		 * 操作按钮处理
		 * @param {Object} value
		 * @param {Object} row
		 * @param {Object} index
		 */
		function getOptionsBtn(value, row, index){
			var btnsHtml = "<span class='optionBtnsArea'>";
			var doSubmitHtml = '<a href="javascript:void(0)" onclick="doSubmit(\'' + row.id + '\')" class="">提交</a>&nbsp;';
			var toUpdateHtml = '<a href="javascript:void(0)" onclick="openDataDialog(projectsParamObj,\'' + row.id + '\')" class="">修改</a>&nbsp;';
			var callBackHtml = '<a href="javascript:void(0)" onclick="doCallback(\'' + row.id + '\')" class="">撤回</a>&nbsp;';
			var infoViewHtml = '<a href="javascript:void(0)" onclick="getProjectDetail(\'' + row.id + '\')" class="">项目详情</a>&nbsp;';
			var cancelHtml = '<a href="javascript:void(0)" onclick="doCancel(\'' + row.id + '\')" class="">撤销</a>&nbsp;';
			var uploadContractHtml='<a href="javascript:void(0)" onclick="uploadContract(\'' + row.id + '\')" class="">上传合同</a>&nbsp;';
			btnsHtml+=doSubmitHtml;
			btnsHtml+=toUpdateHtml;
			btnsHtml+=callBackHtml;
			btnsHtml+=cancelHtml;
			btnsHtml+=infoViewHtml; 
			
			return btnsHtml +"</span>";
		}


		 /**
		 *提交
		 **/
		 function doSubmit(id){
			 top.$.messager.confirm('提示',"您确认要提交吗？",function(result){
				 if(result){
					 $.ajax({
							type: "post",
							url:  "${ctx}/business/projectmanage/doSubmit",
							data:'id=' + id,
							success: function(data,res){
								var result = $.trim(res.responseText);
								if(result == "unLogin"){
									var msn = ''||i18n[''];
									msn = msn||i18n[result];
									if(msn != undefined){
										top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
										return ;
									}
								}
								top.$.messager.alert("提示",'提交成功','info',function(){
									$('#listProjectsTable').datagrid('reload');
								});
								
							},
							error: function(res){
								top.$.messager.alert('提示',i18n.requestError,'error');
							}
						});
				 }
			 });
			 return ;
		 }
		 
		 	/**
			 * 撤回项目操作
			 */
			 function doCallback(id){
					 $.messager.confirm('提示',"你确定对该记录进行撤回吗？",function(result){
					 if(result){
					 		top.$('#firstLevelDialog').dialog({
					 			title:"撤回原因",  
							    iconCls:'icon-view',
							    width: '600',    
							    height: '400',    
							    closed: false,    
							    inline : true,
							    cache: false,    
							    href: "${ctx}/business/projectmanage/getCancelReson?projectId="+id,   
							    modal: true,
							    close: afterClosed,
								extractor : function(data){
									if($.trim(data) == "unLogin"){
										var msn = ''||i18n[''];
										msn = msn||i18n[data];
										if(msn != undefined){
											top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
											return '';
										}
									}
									return data;
								},
							    buttons : [{text:'保存',
										iconCls:'icon-ok',
										handler:function(){
											if(top.$('#addApproveResonForm').form('validate')){
												var cancelReason = top.$("#cancelReason").val();
												if(cancelReason == null || $.trim(cancelReason) == ''){
													top.$.messager.alert('提示',"请输入原因！",'info');
													return;
												}
												$.ajax({
													type: "POST",
													timeout:20000,
													url:  "${ctx}/business/projectmanage/callback",
													data: top.$('#addCancelResonForm').serialize(),
													success: function(data){
														if(data =="success"){
															top.$.messager.alert("提示",'撤回成功','info',function(){
																$('#listProjectsTable').datagrid('reload');
																top.$('#firstLevelDialog').dialog('close');
																//top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
															});
														} else {
															top.$.messager.alert('提示',"撤回失败！",'info');
														}
													},
													error: function(res){
														
													}
												});
											}
											}

										}
									,{
										text:'取消',
										iconCls:'icon-cancel',
										handler:function(){
											top.$('#firstLevelDialog').dialog('close');
										}}],
										onClose : function(){// 解决IE浏览器中无法移除object标签，导致上传插件的flash无法使用，所有的dialog都会出现问题
											//alert(2);
											top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
											afterClosed();
										}
								});
					 		top.$('#firstLevelDialog').dialog("center");
				 			}
					});
			}

			 	/**
				 * 撤销项目操作
				 */
				 function doCancel(id){
						 $.messager.confirm('提示',"你确定对该记录进行撤销吗？",function(result){
						 if(result){
						 		top.$('#firstLevelDialog').dialog({
						 			title:"撤销原因",  
								    iconCls:'icon-view',
								    width: '600',    
								    height: '400',    
								    closed: false,    
								    inline : true,
								    cache: false,    
								    href: "${ctx}/business/projectmanage/getCancelReson?projectId="+id,   
								    modal: true,
								    close: afterClosed,
									extractor : function(data){
										if($.trim(data) == "unLogin"){
											var msn = ''||i18n[''];
											msn = msn||i18n[data];
											if(msn != undefined){
												top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
												return '';
											}
										}
										return data;
									},
								    buttons : [{text:'保存',
											iconCls:'icon-ok',
											handler:function(){
												if(top.$('#addApproveResonForm').form('validate')){
													var cancelReason = top.$("#cancelReason").val();
													if(cancelReason == null || $.trim(cancelReason) == ''){
														top.$.messager.alert('提示',"请输入原因！",'info');
														return;
													}
													$.ajax({
														type: "POST",
														timeout:20000,
														url:  "${ctx}/business/projectmanage/saveCancel",
														data: top.$('#addCancelResonForm').serialize(),
														success: function(data,res){
															if(data == 'success'){
																top.$.messager.alert("提示",'撤销成功','info',function(){
																	top.$('#firstLevelDialog').dialog('close');
																	top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
																	$('#listProjectsTable').datagrid('reload');
																});
															} else {
																top.$.messager.alert('提示',"撤销失败！",'info');
															}
														},
														error: function(res){
															
														}
													});
												}
												}

											}
										,{
											text:'取消',
											iconCls:'icon-cancel',
											handler:function(){
												top.$('#firstLevelDialog').dialog('close');
											}}],
											onClose : function(){// 解决IE浏览器中无法移除object标签，导致上传插件的flash无法使用，所有的dialog都会出现问题
												//alert(2);
												top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
												afterClosed();
											}
									});
						 top.$('#firstLevelDialog').dialog("center");
					 			}
						});
				}
		 
		 /**
		 * 打开添加数据的页面的对话框(添加，修改)
		 * @param {Object} paramObj ： 对应的列表对象
		 * @param {Object} id ： 数据记录的ID
		 * @param {Object} successcallback ：添加数据成功后的回调函数
		 * @param {Object} failurecallback ： 添加数据失败后的回调函数  
		 */
		function openDataDialog(paramObj,id,successcallback,failurecallback){
			if(id == undefined){
				id='';
			}
			var sign = false;
			top.$('#'+paramObj.showDialogId).dialog({    
			    title:paramObj.addDialogTitle,   
			    iconCls:'icon-view',
			    width: paramObj.addDialogWidth,    
			    height: paramObj.addDialogHeight,    
			    closed: false,    
			    inline : true,
			    cache: false,    
			    href: paramObj.updateUrl+id,    
			    modal: true,
				extractor : function(data){
					if($.trim(data) == "unLogin"){
						var msn = ''||i18n[''];
						msn = msn||i18n[data];
						if(msn != undefined){
							top.$.messager.alert('提示',msn,'info',function(){top.location=paramObj.ctx+'/manage';});
							return '';
						}
					}
					return data;
				},
			    buttons : [{text:'提交',
			    		id:'commitEntityBt',
						iconCls:'icon-ok',
						handler:function(){
							if(top.$('#addProjectsDataForm').form('validate')){
								top.$('#commitEntityBt').linkbutton('disable');
							}
			    			submitEntity(paramObj,'saveEntityBt',1);
						}//增加保存按钮
					},{text:'保存',
			    		id:'addEntityBt',
						iconCls:'icon-save',
						handler:function(){
							top.$('#addEntityBt').linkbutton('disable');
						    saveEntity(paramObj,'addEntityBt',0);
						   
						}
					},{
						text:paramObj.cancelButton,//取消
						iconCls:'icon-cancel',
						handler:function(){
							top.$('#'+paramObj.showDialogId).dialog('close');
						}}],
				onClose : function(){// 解决IE浏览器中无法移除object标签，导致上传插件的flash无法使用，所有的dialog都会出现问题
					top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
					top.$("#dealDeclareUpload").uploadify('destroy');//销毁文件上传对象....
					top.$("#proDemandUpload").uploadify('destroy');//销毁文件上传对象....
					top.$("#otherUpload").uploadify('destroy');//销毁文件上传对象....
					if(top.$('#'+paramObj.showDialogId).find("object").length > 0){
						var fileQueue = top.window.document.getElementById("fileQueue");
						fileQueue.innerHTML = "";
						fileQueue.parentNode.removeChild(fileQueue);
					}
					afterClosed();
				}
			});
			top.$('#'+paramObj.showDialogId).dialog("center");
		}
		
		/**
		 *保存按钮操作
		 **/
		function saveEntity(paramObj,opBtId,commitType){
			//alert("保存操作");
			//保存项目
			$.ajax({
				type : "post",
				url : "${ctx}/business/projectmanage/save?r="+new Date().getTime(),
				data : top.$("#addProjectsDataForm").serialize(),
				dataType : "text",
				success : function(data){
					var result=eval("("+data+")");
					//if(data=="success"){
						//top.$(".upload").uploadify('destroy');//销毁文件上传对象....
							top.$.messager.alert("提示",'保存成功','info',function(){
								$('#listProjectsTable').datagrid('reload');
								top.$('#firstLevelDialog').dialog('close');
							});
					
				},
				error : function(data){
					alert("错误");
				}
			});
		}

		/**
		*提交按钮操作
		*/
		function submitEntity(paramObj,opBtId,commitType){
			//alert("提交按钮操作");
			if(top.$('#'+paramObj.addDataFormId).form('validate')){//表单校验是否通过
				//alert("提交按钮操作");
				$.ajax({
					type : "post",
					url : "${ctx}/business/projectmanage/doSubmit?r="+new Date().getTime(),
					data : top.$("#addProjectsDataForm").serialize(),
					success : function(data){
						if(data=="success"){
							//top.$(".upload").uploadify('destroy');//销毁文件上传对象....
								top.$.messager.alert("提示",'提交成功','info',function(){
									$('#listProjectsTable').datagrid('reload');
									top.$('#firstLevelDialog').dialog('close');
								});
						}
						else{
							top.$.messager.alert("提示",'提交失败!');
						}
					},
				error : function(data){
					alert("错误");
				}
				});
			}
		}


		/**
		 * 上传合同操作
		 */
		 function uploadContract(id){
				 		top.$('#firstLevelDialog').dialog({
				 			title:"上传合同",  
						    iconCls:'icon-view',
						    width: '600',    
						    height: '400',    
						    closed: false,    
						    inline : true,
						    cache: false,    
						    href: "${ctx}/business/projectmanage/uploadContract?projectId="+id,   
						    modal: true,
						    close: afterClosed,
							extractor : function(data){
								if($.trim(data) == "unLogin"){
									var msn = ''||i18n[''];
									msn = msn||i18n[data];
									if(msn != undefined){
										top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
										return '';
									}
								}
								return data;
							},
						    buttons : [{text:'提交',
									iconCls:'icon-ok',
									id:'commitEntityBt',
									handler:function(){
										if(top.$("#budgetMenuData").val()==''){
											top.$.messager.alert('提示',"合同附件不能为空！",'info',function(){});
											return;
										}
										top.$('#commitEntityBt').linkbutton('disable');
										if(top.$('#addApproveResonForm').form('validate')){
											$.ajax({
												type: "POST",
												timeout:20000,
												url:  "${ctx}/business/projectmanage/doSubmitContract",
												data: top.$('#addCancelResonForm').serialize(),
												success: function(data){
													if(data =="success"){
														top.$.messager.alert("提示",'提交成功','info',function(){
															$('#listProjectsTable').datagrid('reload');
															top.$('#firstLevelDialog').dialog('close');
															//top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
														});
													} else {
														top.$.messager.alert('提示',"提交失败！",'info');
													}
												},
												error: function(res){
													
												}
											});
										}
										}

									}
								,{
									text:'取消',
									iconCls:'icon-cancel',
									handler:function(){
										top.$('#firstLevelDialog').dialog('close');
									}}],
									onClose : function(){// 解决IE浏览器中无法移除object标签，导致上传插件的flash无法使用，所有的dialog都会出现问题
										//alert(2);
										top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
										afterClosed();
									}
							});
				 		top.$('#firstLevelDialog').dialog("center");
		}
		
		
		
		
		/**
		*项目详情
		*/
		function getProjectDetail(id){
			top.$('#firstLevelDialog').dialog({    
			    title:"项目详情",  
			    iconCls:'icon-view',
			    width: 1000,    
			    height: 580,    
			    closed: false,    
			    inline : true,
			    cache: false,    
			    href: "${ctx}/business/projectmanage/getProjectDetail?projectId=" + id+"&roleId=bizmanager",
			    modal: true,
				extractor : function(data){
					if($.trim(data) == "unLogin"){
						var msn = ''||i18n[''];
						msn = msn||i18n[data];
						if(msn != undefined){
							top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
							return '';
						}
					}
					return data;
				},
			    buttons : [{
						text:projectsParamObj.cancelButton,
						iconCls:'icon-cancel',
						handler:function(){
							top.$('#firstLevelDialog').dialog('close');
						}}]
			});
			top.$('#'+projectsParamObj.showDialogId).dialog("center");
		}


		//关闭
		function afterClosed(){
			// 在弹出对话框内找到Uploadify插件，并隐藏之。
			top.$.find('.upload').hide();
			// 将弹出对话框还原成弹出前的状态，并清空里面的内容。
			top.$('#firstLevelDialog').dialog('destroy').empty();
		}

		 /**
		 *采购确认操作
		 **/
		 function buyerSure(id,type){
			 $.messager.confirm('提示',"是否确认操作",function(result){
				 if(result){
				 		top.$('#firstLevelDialog').dialog({
				 			title:"确认操作",  
						    iconCls:'icon-view',
						    width: '600',    
						    height: '220',    
						    closed: false,    
						    inline : true,
						    cache: false,    
						    href: "${ctx}/business/projectmanage/getCancelReson?projectId="+id+"&type="+type,   
						    modal: true,
						    close: afterClosed,
							extractor : function(data){
								if($.trim(data) == "unLogin"){
									var msn = ''||i18n[''];
									msn = msn||i18n[data];
									if(msn != undefined){
										top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
										return '';
									}
								}
								return data;
							},
						    buttons : [{text:'保存',
									iconCls:'icon-ok',
									id:'commitEntityBt',
									handler:function(){
									if(top.$('#addApproveResonForm').form('validate')){
											var cancelReason = top.$("#cancelReason").val();
											if(type==0){
												if(cancelReason == null || $.trim(cancelReason) == ''){
													top.$.messager.alert('提示',"请输入原因！",'info');
													return;
												}
											}
											
											top.$('#commitEntityBt').linkbutton('disable');
											$.ajax({
												type: "POST",
												timeout:20000,
												url:  "${ctx}/business/projectmanage/buyer/buyerSure",
												data: top.$('#addCancelResonForm').serialize(),
												success: function(data){
													if(data =="success"){
														top.$.messager.alert("提示",'提交成功','info',function(){
															$('#listProjectsTable').datagrid('reload');
															top.$('#firstLevelDialog').dialog('close');
															//top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
														});
													} else {
														top.$.messager.alert('提示',"提交失败！",'info');
													}
												},
												error: function(res){
													
												}
											});
										}
										}

									}
								,{
									text:'取消',
									iconCls:'icon-cancel',
									handler:function(){
										top.$('#firstLevelDialog').dialog('close');
									}}],
									onClose : function(){// 解决IE浏览器中无法移除object标签，导致上传插件的flash无法使用，所有的dialog都会出现问题
										//alert(2);
										top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
										afterClosed();
									}
							});
				 		top.$('#firstLevelDialog').dialog("center");
			 			}
				});
		 }
		 
		  /**
		 *采购人补充资料
		 **/
		 function complete(id){
				 		top.$('#firstLevelDialog').dialog({
				 			title:"确认操作",  
						    iconCls:'icon-view',
						    width: '600',    
						    height: '250',    
						    closed: false,    
						    inline : true,
						    cache: false,    
						    href: "${ctx}/business/projectmanage/complete?projectId="+id,
						    modal: true,
						    close: afterClosed,
							extractor : function(data){
								if($.trim(data) == "unLogin"){
									var msn = ''||i18n[''];
									msn = msn||i18n[data];
									if(msn != undefined){
										top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
										return '';
									}
								}
								return data;
							},
						    buttons : [{text:'保存',
									iconCls:'icon-ok',
									handler:function(){
											$.ajax({
												type: "POST",
												timeout:20000,
												url:  "${ctx}/business/projectmanage/buyer/completeSave",
												data: top.$('#addCancelResonForm').serialize(),
												success: function(data){
													if(data =="success"){
														top.$.messager.alert("提示",'提交成功','info',function(){
															$('#listProjectsTable').datagrid('reload');
															top.$('#firstLevelDialog').dialog('close');
															//top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
														});
													} else {
														top.$.messager.alert('提示',"提交失败！",'info');
													}
												},
												error: function(res){
													
												}
											});
										}
										

									}
								,{
									text:'取消',
									iconCls:'icon-cancel',
									handler:function(){
										top.$('#firstLevelDialog').dialog('close');
									}}],
									onClose : function(){// 解决IE浏览器中无法移除object标签，导致上传插件的flash无法使用，所有的dialog都会出现问题
										//alert(2);
										top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
										afterClosed();
									}
							});
				 		top.$('#firstLevelDialog').dialog("center");
			
		 }

		//===============================================================
		
			/*
			* 中标/流标确认操作
			**/
			function winBidSure(id){
				 $.messager.confirm('提示',"您确认结果吗？",function(result){
					 if(result){
						 $.ajax({
								type: "post",
								url:  "${ctx}/business/projectmanage/buyer/bidEndSure?id="+id,
								success: function(data,res){
									var result = $.trim(res.responseText);
									if(result == "unLogin"){
										var msn = ''||i18n[''];
										msn = msn||i18n[result];
										if(msn != undefined){
											top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
											return ;
										}
									}
									top.$.messager.alert("提示",'操作成功!','info',function(){
										$('#listProjectsTable').datagrid('reload');
									});
									
								},
								error: function(res){
									$.messager.alert('提示',i18n.requestError,'error');
								}
							});
					 }
				 });
			}
		
			/*
			* 结项确认操作
			**/
			function projectEndSure(id){
				 $.messager.confirm('提示',"您确认结项吗？",function(result){
					 if(result){
						 $.ajax({
								type: "post",
								url:  "${ctx}/business/projectmanage/buyer/projectEndSure?id="+id,
								success: function(data,res){
									var result = $.trim(res.responseText);
									if(result == "unLogin"){
										var msn = ''||i18n[''];
										msn = msn||i18n[result];
										if(msn != undefined){
											top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
											return ;
										}
									}
									top.$.messager.alert("提示",'操作成功!','info',function(){
										$('#listProjectsTable').datagrid('reload');
									});
									
								},
								error: function(res){
									$.messager.alert('提示',i18n.requestError,'error');
								}
							});
					 }
				 });
			}
			
			
			/**
			 * 上传验收报告
			 */
			 function receivingReport(id){
					 		top.$('#firstLevelDialog').dialog({
					 			title:"上传验收报告",  
							    iconCls:'icon-view',
							    width: '600',    
							    height: '300',    
							    closed: false,    
							    inline : true,
							    cache: false,    
							    href: "${ctx}/business/projectmanage/buyer/receivingReport?projectId="+id,   
							    modal: true,
							    close: afterClosed,
								extractor : function(data){
									if($.trim(data) == "unLogin"){
										var msn = ''||i18n[''];
										msn = msn||i18n[data];
										if(msn != undefined){
											top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
											return '';
										}
									}
									return data;
								},
							    buttons : [{text:'提交',
										iconCls:'icon-ok',
										id:'commitEntityBt',
										handler:function(){
											if(top.$("#budgetMenuData").val()==''){
												top.$.messager.alert('提示',"报告附件不能为空！",'info',function(){});
												return;
											}
											top.$('#commitEntityBt').linkbutton('disable');
											if(top.$('#addApproveResonForm').form('validate')){
												$.ajax({
													type: "POST",
													timeout:20000,
													url:  "${ctx}/business/projectmanage/uploadReceivingReport",
													data: top.$('#addCancelResonForm').serialize(),
													success: function(data){
														if(data =="success"){
															top.$.messager.alert("提示",'提交成功','info',function(){
																$('#listProjectsTable').datagrid('reload');
																top.$('#firstLevelDialog').dialog('close');
																//top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
															});
														} else {
															top.$.messager.alert('提示',"提交失败！",'info');
														}
													},
													error: function(res){
														
													}
												});
											}
											}

										}
									,{
										text:'取消',
										iconCls:'icon-cancel',
										handler:function(){
											top.$('#firstLevelDialog').dialog('close');
										}}],
										onClose : function(){// 解决IE浏览器中无法移除object标签，导致上传插件的flash无法使用，所有的dialog都会出现问题
											//alert(2);
											top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
											afterClosed();
										}
								});
					 		top.$('#firstLevelDialog').dialog("center");
			}
			
			
			   /**
				 * 终止项目
				 */
				 function cancleProject(id){
						 		top.$('#firstLevelDialog').dialog({
						 			title:"终止项目",  
								    iconCls:'icon-view',
								    width: '600',    
								    height: '400',    
								    closed: false,    
								    inline : true,
								    cache: false,    
								    href: "${ctx}/business/projectmanage/bizmanager/canclePage?projectId="+id,   
								    modal: true,
								    close: afterClosed,
									extractor : function(data){
										if($.trim(data) == "unLogin"){
											var msn = ''||i18n[''];
											msn = msn||i18n[data];
											if(msn != undefined){
												top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
												return '';
											}
										}
										return data;
									},
								    buttons : [{text:'提交',
											iconCls:'icon-ok',
											id:'commitEntityBt',
											handler:function(){
												top.$('#commitEntityBt').linkbutton('disable');
												if(top.$('#addApproveResonForm').form('validate')){
													$.ajax({
														type: "POST",
														timeout:20000,
														url:  "${ctx}/business/projectmanage/bizmanager/closeProject",
														data: top.$('#addCancelResonForm').serialize(),
														success: function(data){
															if(data =="delSuccess"){
																top.$.messager.alert("提示",'终止成功','info',function(){
																	$('#listProjectsTable').datagrid('reload');
																	top.$('#firstLevelDialog').dialog('close');
																	//top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
																});
															} else {
																top.$.messager.alert('提示',"终止失败！",'info');
															}
														},
														error: function(res){
															
														}
													});
												}
												}

											}
										,{
											text:'取消',
											iconCls:'icon-cancel',
											handler:function(){
												top.$('#firstLevelDialog').dialog('close');
											}}],
											onClose : function(){// 解决IE浏览器中无法移除object标签，导致上传插件的flash无法使用，所有的dialog都会出现问题
												//alert(2);
												top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
												afterClosed();
											}
									});
						 		top.$('#firstLevelDialog').dialog("center");
				}
				
			
			
		//打开业务管理员变更项目编号页面
		function editProjectCode(id){
			top.$('#firstLevelDialog').dialog({
	 			title:"修改编号",  
			    iconCls:'icon-view',
			    width: '300',    
			    height: '200',    
			    closed: false,    
			    inline : true,
			    cache: false,    
			    href: "${ctx}/business/projectmanage/bizmanager/projectCodeInput?projectId="+id,
			    modal: true,
			    close: afterClosed,
				extractor : function(data){
					if($.trim(data) == "unLogin"){
						var msn = ''||i18n[''];
						msn = msn||i18n[data];
						if(msn != undefined){
							top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
							return '';
						}
					}
					return data;
				},
			    buttons : [{text:'提交',
						iconCls:'icon-ok',
						id:'commitEntityBt',
						handler:function(){
							if(top.$('#addProjectsDataForm').form('validate')){
								$.ajax({
									type: "POST",
									timeout:20000,
									url:  "${ctx}/business/projectmanage/bizmanager/doSubmitProjectCode",
									data: top.$('#addProjectsDataForm').serialize(),
									success: function(data){
										if(data =="success"){
											top.$.messager.alert("提示",'修改成功','info',function(){
												$('#listProjectsTable').datagrid('reload');
												top.$('#firstLevelDialog').dialog('close');
												//top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
											});
										}else if(data=="codeexit"){ 
											top.$.messager.alert('提示',"修改失败！编号已存在",'error');
										} else {
											top.$.messager.alert('提示',"修改失败！",'error');
										}
									},
									error: function(res){
										
									}
								});
							}
							}

						}
					,{
						text:'取消',
						iconCls:'icon-cancel',
						handler:function(){
							top.$('#firstLevelDialog').dialog('close');
						}}],
						onClose : function(){// 解决IE浏览器中无法移除object标签，导致上传插件的flash无法使用，所有的dialog都会出现问题
							//alert(2);
							top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
							afterClosed();
						}
				});
	 		top.$('#firstLevelDialog').dialog("center");		
		}
			
			
		/**
		 * 打开归档资料选择页面
		 */
		 function pigeonhole(id){//
			 top.$('#firstLevelDialog').dialog({
		 			title:"归档操作",  
				    iconCls:'icon-view',
				    width: '665',    
				    height:'525',    
				    closed: false,    
				    inline : true,
				    cache: false,    
				    href:  "${ctx}/business/projectmanage/leader/pigeonholeInput?projectId="+id,
				    modal: true,
				    close: afterClosed,
					extractor : function(data){
						if($.trim(data) == "unLogin"){
							var msn = ''||i18n[''];
							msn = msn||i18n[data];
							if(msn != undefined){
								top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
								return '';
							}
						}
						return data;
					   },
					   buttons : [
					        {text:'一键导出',
							iconCls:'icon-ok',
							handler:function(){	
								/*$.ajax({
									type:"post",
									url:"${ctx}/business/projectmanage/leader/exportAllFile",
									data:top.$("#pigeonholeForm").serialize(),
									success:function(data){
										top.$('#firstLevelDialog').dialog('close');
									}
								});*/
								top.$("#pigeonholeForm").submit();
								top.$('#firstLevelDialog').dialog('close');
								
							}
							
							}
						,
						{
							text:'取消',
							iconCls:'icon-cancel',
							handler:function(){
								top.$('#firstLevelDialog').dialog('close');
						}}],
	    
					});
		 		top.$('#firstLevelDialog').dialog("center");
		 }
		
		 /**
			 * 打开查看资料选择页面
			 */
			 function viewFile(id){//
				 top.$('#firstLevelDialog').dialog({
			 			title:"归档操作",  
					    iconCls:'icon-view',
					    width: '665',    
					    height:'525',    
					    closed: false,    
					    inline : true,
					    cache: false,    
					    href:  "${ctx}/business/projectmanage/leader/pigeonholeInput?projectId="+id,
					    modal: true,
					    close: afterClosed,
						extractor : function(data){
							if($.trim(data) == "unLogin"){
								var msn = ''||i18n[''];
								msn = msn||i18n[data];
								if(msn != undefined){
									top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
									return '';
								}
							}
							return data;
						   },
						   buttons : [
							{
								text:'取消',
								iconCls:'icon-cancel',
								handler:function(){
									top.$('#firstLevelDialog').dialog('close');
							}}],
		    
						});
			 		top.$('#firstLevelDialog').dialog("center");
			 }
		 
			  //中标结果变更
			 function changeBidder(id){ 
				  top.$('#firstLevelDialog').dialog({
					 			title:"中标结果变更",  
							    iconCls:'icon-view',
							    width: '800',    
							    height:'500',    
							    closed: false,    
							    inline : true,
							    cache: false,    
						        href: "${ctx}/business/projectmanage/bizmanager/getChangePage?projectId="+id,
							    modal: true,
							    close: afterClosed,
								extractor : function(data){
									if($.trim(data) == "unLogin"){
										var msn = ''||i18n[''];
										msn = msn||i18n[data];
										if(msn != undefined){
											top.$.messager.alert('提示',msn,'info',function(){top.location=orderParamObj.ctx+'/manage';});
											return '';
										}
									}
									return data;
								   },
								   buttons :
									   [
								        {text:'提交',
										iconCls:'icon-ok',
										handler:function(){
								        if(top.$("#isBid").val()=="true"){
                                            //评标流程变更
											var arr = top.$("#listProjectsBidTable").datagrid('getSelections');
											if (arr.length < 1) {
												top.$.messager.alert('提示信息','请选择一条一个中标人!', 'info');
												return false;
											}
											if(top.$("#budgetMenuData").val()==''){
												top.$.messager.alert('提示',"变更附件不能为空！",'info',function(){});
												return;
											}
											top.$("#newBidderId").val(arr[0].userId);
											top.$("#projectId").val(arr[0].projectId);
											top.$("#newBidderName").val(arr[0].bidderName);
											top.$('#myform').form('submit', {
												url:'${ctx}/business/projectmanage/bizmanager/changeBidder',
												onSubmit: function(){
												if (!top.$('#myform').form('validate')) {
													top.$.messager.alert('提示信息','验证没有通过,不能提交表单！','info');
													return false; //当表单验证不通过的时候 必须要return false
												   }

												},
												success:function(data){
												   if(data=="saveSuccess"){
														top.$.messager.alert('提示信息','保存成功！','info',function(){
															  top.$('#firstLevelDialog').dialog("close");
															  top.$('#listProjectsTable').datagrid('reload');

														});
													}
													else if(data=="saveUnsuccess"){
														 top.$.messager.alert('提示信息','提交失败！','info');
														}
												}
										  });
										}else{
											//不评标流程变更
                                            var bidArrs = top.$("#listProjectsBidTable").datagrid('getSelections');
                                            if (bidArrs.length < 1) {
                                                top.$.messager.alert('提示信息','请选择一条一个中标人!', 'info');
                                                return false;
                                            }
                                            if(top.$("#budgetMenuData").val()==''){
                                                top.$.messager.alert('提示',"变更附件不能为空！",'info',function(){});
                                                return;
                                            }
                                            var bidIds = '';
                                            for(var i=0;i<bidArrs.length;i++){
                                                bidIds += bidArrs[i].userId+",";
                                            }
                                           // bidIds += bidArrs[bidArrs.length-1].id;
                                            top.$("#projectId").val(bidArrs[0].projectId);
                                            if(top.$('#myform').form('validate')){
                                                $.ajax({
                                                    type: "POST",
                                                    timeout:20000,
                                                    url:'${ctx}/business/projectmanage/bizmanager/changeBidderNoEvaluation',
                                                    data: {
                                                        ids:bidIds,
														projectId:top.$("#projectId").val(),
														bidReason:top.$("#changeReason").val(),
                                                        budgetMenuData: top.$("#budgetMenuData").val()
													},
                                                    success: function(data){
                                                        if(data =="success"){
                                                            top.$.messager.alert("提示",'变更中标结果成功','info',function(){
                                                                $('#listProjectsTable').datagrid('reload');
                                                                top.$('#firstLevelDialog').dialog('close');
                                                            });
                                                        }else if(data=="removeIsMultHitError"){
                                                            top.$.messager.alert('提示',"修改原中标人中标结果！",'error');
                                                            top.$('#firstLevelDialog').dialog('close');
                                                        }else if(data="setIsMultHitError"){
                                                            top.$.messager.alert('提示',"变更中标结果失败！",'error');
                                                            top.$('#firstLevelDialog').dialog('close');
														}else if(date="saveBgError"){
                                                            top.$.messager.alert('提示',"保存修改记录失败！",'error');
                                                            top.$('#firstLevelDialog').dialog('close');
														}
                                                    }
                                                });
                                             }
										   }
								          }
										},
									 {
										text:'取消',
										iconCls:'icon-cancel',
										handler:function(){
											  top.$('#firstLevelDialog').dialog("close");
										}
									  }
									],
									onClose : function(){// 解决IE浏览器中无法移除object标签，导致上传插件的flash无法使用，所有的dialog都会出现问题
										top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
										afterClosed();
									}
								});
					 		$('#firstLevelDialog').dialog("center");
			              }
     </script>